arch: add baudbot attach and sessions commands#34
Merged
Conversation
baudbot sessions — lists all tmux sessions and pi agent sessions under the baudbot_agent user, with running/stopped status. baudbot attach [name] — attaches to a tmux session. Defaults to the first available session if no name given. Useful for inspecting the slack-bridge or agent output.
Greptile SummaryThis PR adds two new operator-facing subcommands to the Key findings:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Admin as Admin User (root)
participant Baudbot as bin/baudbot
participant Tmux as tmux (baudbot_agent)
participant PiFS as ~/.pi/agent/sessions/
Note over Admin,PiFS: baudbot sessions
Admin->>Baudbot: sudo baudbot sessions
Baudbot->>Tmux: sudo -u baudbot_agent tmux ls
Tmux-->>Baudbot: session list (or empty)
Baudbot->>PiFS: stat ~/.pi/agent/sessions/*/
PiFS-->>Baudbot: sess_dir entries
loop each session dir
Baudbot->>PiFS: check control.sock / pid file
PiFS-->>Baudbot: status = running / stopped
Baudbot->>PiFS: read name file
PiFS-->>Baudbot: session name
end
Baudbot-->>Admin: formatted session list
Note over Admin,Tmux: baudbot attach [name]
Admin->>Baudbot: sudo baudbot attach [name]
alt no name given
Baudbot->>Tmux: sudo -u baudbot_agent tmux ls -F #{session_name}
Tmux-->>Baudbot: first session name
end
Baudbot-->>Admin: print attach instructions
Baudbot->>Tmux: exec sudo -u baudbot_agent tmux attach-session -t TARGET
Tmux-->>Admin: interactive tmux session
Last reviewed commit: 5113760 |
- Add require_root guard to both sessions and attach commands - Fix help text: 'default: first available' not 'control-agent' - Fix stale socket false-positive: prefer pid file for liveness, fall back to socat socket probe, label stale sockets clearly
The sessions command was looking in ~/.pi/agent/sessions/ (history logs as .jsonl files) and checking for pid/name files that pi doesn't create. All sessions would report as 'stopped'. Now reads ~/.pi/session-control/*.sock (where pi actually puts live control sockets). Resolves alias symlinks to show session names. Liveness check tries socat, falls back to python3 socket connect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New commands
baudbot sessionsLists all tmux and pi sessions running under
baudbot_agent:baudbot attach [name]Attaches to a tmux session under the agent user. Defaults to the first available session.
Prints detach instructions (
Ctrl+b, d) before attaching.